<style>
    th, tr {
        text-align: center;
        vertical-align:middle;
    }

    label {
        display: inline-block;
        max-width: 100%;
        margin-bottom: 5px;
        font-weight: 400;
        font-size: 16px;
    }

    select {
        width: 150px !important;
    }

    .form-group {
        margin-left: 15px;
        margin-top: 15px;
    }

    form {
        padding: 10px 10px 0 10px;
    }

    hr {
        margin-bottom: 0;
    }
    .no-padding{
        overflow: scroll;
    }
    .course {
        margin-bottom: 12px;
    }
    .this-week {
        width: 160px;
    }
</style>

<div class="panel panel-default panel-intro">
    {:build_heading()}
    <form class="form-inline" role="form">
        <input id="user_id" type="hidden" value="">
<!--        <h4>数据操作区</h4>-->
        <hr>
        <div class="form-group">
            <label>班级：</label>
            <select class="form-control operate" id="classes">
                {foreach name="classes" item="vo"}
                <option value="{$vo->id}" id="classes-{$vo->id}" name="classes">{$vo->class_name}</option>
                {/foreach}
            </select>
        </div>
        <div class="form-group">
            <label>教师：</label>
            <select class="form-control operate" id="teacher">
                <option value="0">无</option>
                {foreach name="teachers" item="vo"}
                <option value="{$vo->id}" id="teacher-{$vo->id}" name="teacher">{$vo->username}</option>
                {/foreach}
            </select>
        </div>
        <div class="form-group">
            <a href="javascript:;" class="btn btn-success" data-event="prev_week" id="last-week">上周</a>
            <input class="btn btn-info datetimerange this-week" data-time="" data-event="now_week" data-date-format="YYYY-MM-DD" id="this-week" value="">
            <a href="javascript:;" class="btn btn-success" data-event="next_week" id="next-week">下周</a>
        </div>
    </form>

    <div class="panel-body">
        <div id="myTabContent" class="tab-content">
            <div class="tab-pane fade active in" id="one">
                <div class="widget-body no-padding">

                    <table class="table table-striped table-bordered table-hover table-nowrap" id="table">
                        <thead>
                            <tr id="thead">
                                <!--表头数据-->

                            </tr>
                        </thead>
                        <tbody id="tbody">
                            <!--表内数据-->


                        </tbody>
                    </table>
                </div>
            </div>

        </div>
    </div>
</div>


<!--表头数据-->
<script id="temp-thead" type="text/html">
    <th>时间段</th>
    {{#each dates date}}
    <th>{{#date.date}}({{#date.week}})</th>
    {{#/each}}
</script>

<script id="temp-tbody" type="text/html">
    <tr>
        <td></td>
        {{#each dates date}}
        <td data-date="{{#date.date}}"><a href="javascript:;" class="btn btn-info btn-add">添加课程</a></td>
        {{#/each}}
    </tr>
    {{#each courses course c}}
        <tr>
            <td class="{{#if c == 'am'}}am{{#else}}pm{{#/if}}">{{#if c == 'am'}}上午{{#else}}下午{{#/if}}</td>
            {{#each dates date}}
            <td>
                {{#each course value key}}
                {{#if key == date.date}}
                {{#each value v}}
                <div class="course">
                    <div><span>{{#v.time}}</span></div>
                    <div><span>{{#v.timetable_cn}}</span></div>
                    <div><span>{{#v.timetable_en}}</span></div>
                    <div><span>{{#if v.teacher}}{{#v.teacher.username}}{{#/if}}</span></div>
                    <div>
                        <a href="javascript:;" class="btn btn-xs btn-success btn-edit" data-id="{{#v.id}}">编辑</a>
                    </div>
                </div>

                {{#/each}}
                {{#/if}}
                {{#/each}}
            </td>
            {{#/each}}
        </tr>
    {{#/each}}
</script>